#pragma once
#ifndef _CMENU_
#define _CMENU_
#include <d3d9.h>
#include <d3dx9.h>
#include <stdio.h>
#include <string>
#include "cTools.h"

extern ID3DXFont* pFont, *pFontTitle;
extern cTools* pTools;

#define ITEMS_NUM 50
#define ITEM_HEIGH 15

using std::string;

class cMenu{
public:
	VOID AddItem(PCHAR ItemName, bool IsFolder, PSHORT ItemNum, PCHAR ItemOpt = NULL);
	VOID DrawMenu(LPDIRECT3DDEVICE9 pDevice);
	VOID DrawTxt(INT X, INT Y, D3DCOLOR Cor, ID3DXFont *font, CONST PCHAR txt, DWORD flag  = DT_LEFT) ; 
	VOID CheckForItems();
	
	UINT SCREEN_WIDTH;
	UINT SCREEN_HEIGHT;
	UINT MENU_BORDER_SIZE;

	cMenu();
	~cMenu();

private:
	struct sITEM{
		PCHAR ItemName;
		bool IsFolder; 
		PSHORT ItemNum;
		bool IsVisible;
		PCHAR* opt;
		SHORT OptNum;
		SHORT CurOptNum;
		string* s_opt;
	}ITEM[ITEMS_NUM];
	
	VOID WINAPI DrawBox(LPDIRECT3DDEVICE9 pDevice, FLOAT x, FLOAT y, FLOAT w, FLOAT h, D3DCOLOR Color);
	VOID WINAPI DrawMenuBoxes(LPDIRECT3DDEVICE9 pDevice, FLOAT x, FLOAT y, FLOAT w, D3DCOLOR TitleColor, D3DCOLOR BodyColor, D3DCOLOR BorderColor);

	UINT CUR_OPT;
	UINT ACTIVE_ITEMS;
	UINT CUR_VISIBLE_ITEMS;

	//--------------------------------------// 
	UINT MENU_X;
	UINT MENU_Y;
	UINT MENU_HEIGHT;
	UINT MENU_WIDTH;
	UINT MENU_TITLEBOX_HEIGHT;
	UINT MENU_LEFT_TEXT_ALIGNMENT;
	UINT MENU_LEFT_TEXT_IN_FOLDER_ALIGNMENT;
	UINT MENU_TOP_TEXT_ALIGNMENT;
	UINT MENU_RIGHT_TEXT_ALIGNMENT;
	UINT MENU_HEIGHT_OFFSET;
	//--------------------------------------//

	PCHAR ItemOpt_copy;
	SHORT ItemOpt_len, real_ItemOpt_len;
};

#endif